<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>找到所有消失的数字</title>
</head>

<body>
  <script>
    var Numbers = function (nums) {
      const resArr = []
      //首先循环数组
      for (let i = 0; i < nums.length; i++) {
        if (nums.indexOf(i + 1) === -1) resArr.push(i + 1)
        //       判断下标+1(nums[i] 在区间 [1, n] 内),是否存在数组中
        //       没值的话，直接添加到空数组中
        //        循环完成后返回用来存放不存在的值
      }
      return resArr
    };
    console.log(Numbers(nums = [4, 3, 2, 7, 8, 2, 3, 1]))
  </script>
</body>

</html>